import java.util.Scanner;

public class Frog {
    static int sum;
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int with=scanner.nextInt();//河的宽度
        int day=scanner.nextInt();
         sum=day*2;//需要过河的次数
        int x;//要求的青蛙能过河的最小跳跃能力
        int []arr1=new int[with-1];
        int []arr2=new int[with-1];//记录该含点之前的石头数量和
        int temp=with-1;
        int i=0;
        int s=0;
        while (temp>0){
            int high=scanner.nextInt();
            arr1[i]=high;
            s+=arr1[i];
            arr2[i]=s;
            i++;
            temp--;
        }
        //二分查找
        int left=0;int right=with-1;int ret=0;
        while (left<=right){
            int mid=(left+right)/2;
            if(dx(arr2,mid)){

                ret=mid;
                right=mid-1;
            }
            else{
                left=mid+1;
            }
        }
        x=ret;
        System.out.println(x);
    }
    public static boolean dx(int []arr2,int mid){
        //判断区间是否有大于等于sum的石头
        for(int i=0;i+mid<arr2.length;i++){
            if(arr2[i+mid]-arr2[i]<sum){
                return false;
            }
        }
        return true;
    }
}
